package com.gblfy.shopcart.controller;

import com.gblfy.api.dubbo.IDubboService;
import com.gblfy.api.dubbo.IDubboService2;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api()
@RestController
public class DubboController {

    @DubboReference
    private IDubboService dubboService;
    @DubboReference
    private IDubboService2 dubboService2;

    /**
     * ly-shop-cart调用ly-user的dubbo服务
     *
     * @param name
     * @return
     */
    @GetMapping("/getDubboHello")
    public String getDubboHello(@RequestParam("name") String name) {
        return dubboService.getDubboHello(name);
    }

    /**
     * ly-shop-cart调用ly-user的dubbo服务，接着ly-user调用ly-stock模块的dubbo服务
     *
     * @param name
     * @return
     */
    @GetMapping("/getDubboRedirect")
    public String getDubboRedirect(@RequestParam("name") String name) {
        return dubboService.getDubboHello(name);
    }

    @GetMapping("/getDubboHello2")
    public String getDubboHello2(@RequestParam("name") String name) {
        return dubboService2.getDubboHello2(name);
    }
}
